package x.y.z.mapper;

import org.springframework.jdbc.core.RowMapper;
import x.y.z.bean.DictType;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.time.ZoneId;

public class DictTypeMapper implements RowMapper<DictType> {
    @Override
    public DictType mapRow(ResultSet resultSet, int i) throws SQLException {
        DictType dictType = new DictType();
        dictType.setId(resultSet.getLong("dict_id"));
        dictType.setType(resultSet.getString("dict_type"));
        dictType.setName(resultSet.getString("dict_name"));
        dictType.setRemark(resultSet.getString("remark"));
        dictType.setStatus(resultSet.getByte("status"));

        dictType.setCreateBy(resultSet.getString("create_by"));
        dictType.setUpdateBy(resultSet.getString("update_by"));

        dictType.setCreateTime(resultSet.getDate("create_date").toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());
        dictType.setUpdateTime(resultSet.getDate("update_date").toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime());

        return dictType;
    }
}
